﻿// ===============================================================================
// XCI.Parent 西安交通信息WinForm开发框架 2019 版权所有
// ===============================================================================

using System;
using System.Threading.Tasks;
using XCI.Helper;
using XCI.Sys.Service;
using XCI.Windows;

namespace XCI.Sys.Forms
{
    /// <summary>
    /// 系统操作日志详情
    /// </summary>
    public partial class FrmOperateLogDetails : BaseForm
    {
        private readonly GridControlPlus gridControl;
        public FrmOperateLogDetails(GridControlPlus gridControl)
        {
            InitializeComponent();
            this.gridControl = gridControl;
        }

        private async Task BindingModelAsync()
        {
            var model = await SysLogService.Instance.SelectOperateLogByIdAsync(gridControl.SelectedId);
            model.Msg = StringHelper.ReplaceEnter(model.Msg);
            model.ReqParam = StringHelper.ReplaceEnter(model.ReqParam);
            bindingSource.DataSource = model;
            btnPrev.Enabled = !gridControl.IsFirstFocus;
            btnNext.Enabled = !gridControl.IsLastFocus;
        }

        private async void Form_Load(object sender, EventArgs e)
        {
            await BindingModelAsync();
        }

        private async void btnPrev_Click(object sender, EventArgs e)
        {
            gridControl.CurrentColumnView.MovePrev();
            await BindingModelAsync();
        }

        private async void btnNext_Click(object sender, EventArgs e)
        {
            gridControl.CurrentColumnView.MoveNext();
            await BindingModelAsync();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            DialogCancel();
        }
    }
}